import EventManage from "../event/EventManage";
import BaseUI from "./BaseUI";
import UIConfig from "../config/UIConfig";

export class LayerUI extends Laya.Sprite {

    // maskLayer: Laya.Sprite = new Laya.Sprite()
    // private views = new Map<number, BaseUI<any>>();
    static $gid: number = 0;

    layerId: number;

    constructor(name: string) {
        super();
        this.layerId = ++LayerUI.$gid;
        this.name = name;
        this.mouseThrough = true;
        // Laya.stage.on(Laya.Event.RESIZE, this, this._onResize);
        // this._onResize();
        // this.maskLayer.on(Laya.Event.CLICK, this, this._closeOnSide);
    }


    add(gid: number, node: BaseUI<any>) {
        // this.addChild(this.maskLayer);

        this.addChild((<any>node).view);
    }

    remove(node: BaseUI<any>) {
        // this.maskLayer.removeSelf();
        this.removeChild((<any>node).view);
    }


    //     private _onResize(e?: Laya.Event) {
    //         // let f = new Laya.ColorFilter();
    //         let width = Laya.stage.width;
    //         let height = Laya.stage.height;
    //         this.size(width, height);
    //         this.views.forEach(v => v.onResize);

    //         // this.maskLayer.size(width, height)
    //         // this.maskLayer.graphics.clear(true);
    //         // this.maskLayer.graphics.drawRect(0, 0, width, height, UIConfig.popupBgColor);
    //         // this.maskLayer.alpha = UIConfig.popupBgAlpha;
    //     }
}




